<%@ page import="com.hrm.entity.EmployeeEntity" %><%--
  Created by IntelliJ IDEA.
  User: zekdot
  Date: 20-3-10
  Time: 下午9:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <%--<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/table.css">--%>
    <link href="${pageContext.request.contextPath}/css/main.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">

    <script src="${pageContext.request.contextPath}/js/date/js/laydate.js"></script>
    <script src="${pageContext.request.contextPath}/bstable/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/bstable/js/bootstrap-table.js"></script>
    <script src="${pageContext.request.contextPath}/bstable/js/bootstrap-table-zh-CN.min.js"></script>
</head>
<body>

<div class="tabe_div">
    <p class="p_line text_ient"><a class="find_a">员工编号：</a>
        <input type="text" class="form_input text_ient" placeholder="输入编号" id="id"/>
        <input type="button" id="search" value="查看信息" class="but_find"/>
    <p>
    <p class="p_table">
    </p>


    <table id="table" class="table_style" style="margin: 0 auto" >
    </table>
</div>
    <script>
        $('#table').bootstrapTable({
            method:"get",
            striped: true,
            singleSelect: false,
            url:"${pageContext.request.contextPath}/employee/employers",
            dataType: "json",
            pagination: true, //分页
            pageSize: 10,
            pageNumber: 1,
            search: false, //显示搜索框
            contentType: "application/x-www-form-urlencoded",
            queryParams: null,
            columns: [
                {
                    title: "员工编号",
                    field: 'id',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '部门',
                    field: 'department',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '职位',
                    field: 'position',
                    align: 'center'
                },
                {
                    title: '在职情况',
                    field: 'status',
                    align: 'center',
                    formatter:function(value,row){
                        if(row.status == 0)
                            return '在职';
                        else
                            return '离职';
                    }
                },
                {
                    title: '操作',
                    field: 'oper',
                    align: 'center',
                    formatter: function (value, row) {


                        var e = '<button onclick="location.href=\'${pageContext.request.contextPath}/employee/editInfoPage?id=' + row.id + '\'">档案管理</button>';
                        var d = '<button onclick="location.href=\'${pageContext.request.contextPath}/employee/editSalaryPage?id=' + row.id + '\'">薪水管理</button>';
                        return e + d;
                    }
                }
            ]
        });
        function tranStatus(status){
            if(status == 0){
                return '在职';
            }else{
                return '离职';
            }
        }
        $('#search').click(function () {
            var id = $('#id').val();
            var data = {'id':id};
            $.post('${pageContext.request.contextPath}/employee/get',data,function(str){
                var res = eval('(' + str + ')');

                if(res.code != 0){
                    alert(res.message);
                    return;
                }
                var datas = [];
                datas.push(res.object);
                var setsData = {"data":datas};
                // console.log(JSON.stringify(setsData))
                $('#table').bootstrapTable('load',setsData);
            });
        });

    </script>
</body>
</html>
